home *** CD-ROM | disk | FTP | other *** search
- /**********************************************************************
- * This file contains the functions which start off the program. The
- * main event loop and Macintosh toolbox definitions are in this
- * file.
- **********************************************************************/
-
- #include "Creator Changer.h"
- #include "Creator Changer.start.h"
-
-
-
- /**********************************************************************
- * Function main(), this is the main function of the program. The
- * major parts of the program are called in this function.
- **********************************************************************/
-
- void main(void)
- {
-
- Init_Toolbox();
- Set_Up_Menu_Bar();
- // Check_Sys_Type();
- Main_Event_Loop();
-
- }
-
-
-
- /**********************************************************************
- * Function Init_Toolbox(), this function initializes the Macintosh
- * toolbox so that all of the parts of the program will work.
- **********************************************************************/
-
- void Init_Toolbox(void)
- {
-
- InitGraf(&thePort);
- InitFonts();
- InitWindows();
- InitMenus();
- FlushEvents(everyEvent, REMOVE_EVENTS);
- TEInit();
- InitDialogs(NIL_PTR);
- InitCursor();
- MaxApplZone();
-
- MoreMasters();
- MoreMasters();
- MoreMasters();
-
- }
-
-
-
- /**********************************************************************
- * Function Set_Up_Menu_Bar(), this function displays the menu bar
- * for the program.
- **********************************************************************/
-
- void Set_Up_Menu_Bar(void)
- {
-
- SetMenuBar(GetNewMBar(MAIN_MENU_BAR_ID));
- Apple_Menu=GetMHandle(APPLE_MENU_ID);
- AddResMenu(Apple_Menu, 'DRVR');
- Options_Menu=GetMHandle(OPTIONS_MENU_ID);
- DrawMenuBar();
-
- }
-
-
- /* I commented this block out because I think I found out why the
- * program would not work on System 6. I really think that it was
- * just a fluke problem that happened on that computer, but I am not
- * sure, as I do not have acess to a System 6 machine anymore.
- */
- /**********************************************************************
- * Function Check_Sys_Type(), this function checks to see if System
- * seven or later is present, if it isn't then the program quits.
- **********************************************************************/
- /*
- void Check_Sys_Type(void)
- {
-
- short sys_7=0x0700; // hexadecimal value for system seven.
- short vers_requsted=1; // I just know this gives me what I want.
- SysEnvRec the_environ;
-
- SysEnvirons(vers_requsted, &the_environ);
-
- if(the_environ.systemVersion>=sys_7) All_Done=FALSE;
- else
- {
- ParamText("\pSystem 7 or later is required!!", "\p", "\p Sorry!", "\p");
- Alert(ERROR_ALERT, NIL_PTR);
- All_Done=TRUE;
- }
-
- }
- */
-
-
-
- /**********************************************************************
- * Function Main_Event_Loop(), this function sets up the main event
- * loop. This function also cheks to see if multifinder is active.
- **********************************************************************/
-
- void Main_Event_Loop(void)
- {
- // I have no clue how this works, but it does determine if ...
- // ... multifinder is active or not.
- Multifinder_Active=(NGetTrapAddress(WNE_TRAP_NUM, ToolTrap)!=
- NGetTrapAddress(UNIMPL_TRAP_NUM, ToolTrap));
- // Open the "Open Dialog" box at start-up
- Handle_Options_Choice(O_OPEN_ITEM);
- // The MainEvent loop
- while(All_Done==FALSE) Handle_One_Event();
-
- }
-
-
-
- /**********************************************************************
- * Function Handle_One_Event(), this function handles one event.
- * Depending on what the event is, it gets directed to the
- * appropriate place.
- **********************************************************************/
-
- void Handle_One_Event(void)
- {
-
- if(Multifinder_Active==TRUE)
- WaitNextEvent(everyEvent, &The_Event, SLEEP_TICKS, MOUSE_REGION);
- else
- {
- SystemTask();
- GetNextEvent(everyEvent, &The_Event);
- }
- switch(The_Event.what)
- {
- case mouseDown:
- Handle_Mouse_Down();
- break;
- case keyDown:
- case autoKey:
- Handle_Auto_Key();
- break;
- }
-
- }
-
-
-
- /**********************************************************************
- * Function Handle_Mouse_Down(), this function handles any mouse down
- * event, such as a window select, in the menu bar etc.
- **********************************************************************/
-
- void Handle_Mouse_Down(void)
- {
-
- WindowPtr which_window;
- short the_part;
- long menu_choice;
-
- the_part=FindWindow(The_Event.where, &which_window);
-
- switch(the_part)
- {
- case inMenuBar:
- menu_choice=MenuSelect(The_Event.where);
- Handle_Menu_Choice(menu_choice);
- break;
- case inSysWindow:
- SystemClick(&The_Event, which_window);
- break;
- case inContent:
- SelectWindow(which_window);
- break;
- }
-
- }
-
-
-
- /**********************************************************************
- * Function Handle_Auto_Key(), this function handles command key
- * events for the menu items.
- **********************************************************************/
-
- void Handle_Auto_Key(void)
- {
-
- register char command_key;
-
- command_key=The_Event.message;
- if(The_Event.modifiers!=0) Handle_Menu_Choice(MenuKey(command_key));
-
- }
-
-
-
- /**********************************************************************
- * Function Handle_Menu_Choice(), this function handles the menu
- * choice made, then it directs it to the appropriate place.
- **********************************************************************/
-
- void Handle_Menu_Choice(long menu_choice)
- {
-
- int the_menu;
- int the_menu_item;
-
- if(menu_choice!=0)
- {
- the_menu=HiWord(menu_choice);
- the_menu_item=LoWord(menu_choice);
-
- switch(the_menu)
- {
- case APPLE_MENU_ID:
- Handle_Apple_Choice(the_menu_item);
- break;
- case OPTIONS_MENU_ID:
- Handle_Options_Choice(the_menu_item);
- break;
- defualt:
- break;
- }
- HiliteMenu(0);
- }
-
- }